/**
 * 我的零件平台---修改设计的JS文件
 */

$(document).ready(function(){
	//rightFormSubmit();//右侧细节设置修改提交
});

//根据零件类型加载我的零件库列表
function getMyPartList(partstype){ 
	  $.ajax({  
	        type : "POST",  
	        url : CONTEXT_PATH+'front/partDesign/getMyPartList?partsType='+partstype,  
	        dataType : "json",  
	        cache : false,  
	        async : false,  
	        success : function(data) {  
               $(".left-twoImgList.listImgBox").empty();
               
               for(i=0;i<data.length;i++){
                   $(".left-twoImgList.listImgBox").append(
       					"<div class='left-twoImgBlock leftImgBlock "+(data.id==$("#partsNo").val()? 'activeImg':'')+"'>"+
       					"<div class='left-twoImgBox'><img src='"+FILESERVER_PATH+"?id="+data[i].physicalmap+"'/></div>"+
       					"<div class='left-oneImgName'>"+data[i].designame+"</div>"+
       				        "<input type='hidden' value="+JSON.stringify(data[i])+">"+
       				    "</div>");
               }
               imgSelectControl();
               
	        }  
	    }); 
	
}

/*function rightFormSubmit(){
	$("#formSubmit").click(function(){
		$("#myPartsModifyModal").modal('show');
	});
	
}*/

 

function submitForm(id){
	
	if(!$.trim($("#designame").val())){
		   jAlert("文件名不能为空","提示");
		   return;
	  }
 
	   $('#myPartDesignform').ajaxSubmit({
		   	type : "POST",
		    url: CONTEXT_PATH+'front/partDesign/updateMyPartDesign',
		    dataType: "json",
		    cache : false,  
	        async : false,
		    success: function(data) {  
		    	if(data.result){
             	 
		    		$("#myPartsModifyModal").modal('show');
		    		//window.location.href= CONTEXT_PATH+'front/partDesign/partDesign_list';
             	
		    	}else{
		    		jAlert("修改失败！","提示");
		    	}
		    	
		    }   
		  	
	  });  
}

function download(designid){
    
    $("#designid").val(designid);
    $("input[name='chose']").prop("checked",false);
	$("#loadModal").modal('show');
 
}

function submitDownload(){

	if ($("input[name='chose']:checked").length!=0) {
		$("#downloadForm").submit();
		$("#loadModal").modal('hide');
	}else{
		jAlert("请先至少选中一个","提示");
	}

}

function designameVerify(param,userid){
	var designame=$("#designame").val();
	$.ajax({
		type : "POST",
		url : CONTEXT_PATH+'front/partDesign/designameVerify?param='+param+'&designame='+designame+'&userid='+userid,
		dataType : "json",
		cache : false,
		async : false,
		success : function(data){
			if(data.result == false){
				$("#designame").val('');
				jAlert(data.msg,"提示");
			}
		}
	});
}